import wepy from 'wepy'

export default class extends wepy.mixin {
    config = {}

    data = {
        swiperList: [],
        catesList: [],
        floorList: []
    }

    methods = {
        goGoodsList(url) {
            wepy.navigateTo({ url })
        }
    }

    async getSwiperData() {
        var { data: res } = await wepy.get('/home/swiperdata')
        console.log(res)

        if (res.meta.status != 200) {
            return wepy.baseToast()
        }
        this.swiperList = res.message
        this.$apply()
    }

    async getCatesData() {
        var { data: res } = await wepy.get('/home/catitems')
        console.log(res)

        if (res.meta.status != 200) {
            return wepy.baseToast()
        }
        this.catesList = res.message
        this.$apply()
    }

    async getFloorsData() {
        var { data: res } = await wepy.get('/home/floordata')
        console.log(res)

        if (res.meta.status != 200) {
            return wepy.baseToast()
        }
        this.floorList = res.message
        this.$apply()
    }

    onLoad() {
        this.getSwiperData(),
            this.getCatesData(),
            this.getFloorsData()
    }
}